package com.bank.backend.boot.server.controller;

import com.bank.backend.boot.base.model.dto.ModelDTO;
import com.bank.backend.boot.base.model.dto.TradeDTO;
import com.bank.backend.boot.base.model.dto.TradeQueryDTO;
import com.bank.backend.boot.base.model.dto.TradeQueryPageDTO;
import com.bank.backend.boot.base.model.vo.PageVO;
import com.bank.backend.boot.base.model.vo.TradeInfoVO;
import com.bank.backend.boot.server.annotation.ResponseResult;
import com.bank.backend.boot.server.service.TradeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jiaowei
 * @since 2025/3/30 15:32
 */
@Slf4j
@Tag(name = "交易信息")
@RestController
@RequestMapping("/trade")
public class TradeController {
    @Resource
    private TradeService tradeService;

    @Operation(summary = "获取交易信息（识别")
    @PostMapping("/modelTrade")
    @ResponseResult
    public boolean modelTrade(@RequestBody ModelDTO modelDTO) {
        log.warn("模型参数：{}", modelDTO);
        return tradeService.modelTrade(modelDTO);
    }

    @Operation(summary = "新增交易信息(普通)")
    @PostMapping("/saveTrade")
    @ResponseResult
    public boolean saveTrade(@RequestBody TradeDTO tradeDTO) {
        return tradeService.saveTrade(tradeDTO);
    }

    @Operation(summary = "根据id查询交易信息")
    @GetMapping("/queryTradeById/{id}")
    @ResponseResult
    public TradeInfoVO queryTradeById(@PathVariable("id") Long id) {
        return tradeService.queryTradeById(id);
    }

    @Operation(summary = "查询所有交易信息")
    @GetMapping("/queryTradeList")
    @ResponseResult
    public List<TradeInfoVO> queryTradeList() {
        return tradeService.queryTradeList();
    }

    @Operation(summary = "根据用户id查询交易信息")
    @GetMapping("/queryTradeListByUid/{uid}")
    @ResponseResult
    public List<TradeInfoVO> queryTradeListByUid(@PathVariable("uid") Long uid) {
        return tradeService.queryTradeListByUid(uid);
    }

    @Operation(summary = "根据参数查询交易信息")
    @PostMapping("/queryTradeListByAid")
    @ResponseResult
    public List<TradeInfoVO> queryTradeListByAid(@RequestBody TradeQueryDTO tradeQueryDTO) {
        return tradeService.queryTradeListByParam(tradeQueryDTO);
    }

    @Operation(summary = "分页查询交易信息")
    @PostMapping("/queryTradePage")
    @ResponseResult
    public PageVO<TradeInfoVO> queryTradePage(@RequestBody TradeQueryPageDTO tradeQueryPageDTO) {
        return tradeService.queryTradePage(tradeQueryPageDTO);
    }

    @Operation(summary = "人工审核交易（分页）")
    @GetMapping("/manual/{current}/{pageSize}")
    @ResponseResult
    public PageVO<TradeInfoVO> manual(@PathVariable("current") int current, @PathVariable("pageSize") int pageSize) {
        log.warn("人工审核交易入参：current:{},pageSize:{}", current, pageSize);
        return tradeService.queryManualPage(current, pageSize);
    }

}
